package gimys;

import java.util.ArrayList;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

public class IntroState extends BasicGameState {

	private int ID;
	private ArrayList<Image> backgrounds;
	private int current = 0;

	public IntroState(int menuState) throws SlickException {
		this.ID = menuState;
	}

	public int getID() {
		return this.ID;
	}

	@Override
	public void init(GameContainer container, StateBasedGame game) throws SlickException {
		this.backgrounds = new ArrayList<Image>();
		for (int i = 0; i< 3; i++) {
			this.backgrounds.add(new Image("data/Intro-0" + i + ".png"));
		}
	}

	@Override
	public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
		//System.out.println("print intro "+current);
		this.backgrounds.get(current).draw(0,0,GimysGame.displayHeight,GimysGame.displayWidth);
	}

	@Override
	public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
		Input input = container.getInput();
		if(input.isKeyPressed(Input.KEY_SPACE)) {
			if (current < 2) {
				current ++;
			} else {
				game.enterState(GimysGame.GAMEPLAYSTATE);
			}
		}
	}

}
